package com.wc.算法基础课.B第二讲数据结构.并查集.奶酪;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/20 22:28
 * @description https://www.acwing.com/problem/content/530/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 1010;
    static int[] p = new int[N];
    static long[][] a = new long[N][3];
    static int t, n, h, r;

    public static void main(String[] args) {
        t = sc.nextInt();
        while (t-- > 0) {
            n = sc.nextInt();
            h = sc.nextInt();
            r = sc.nextInt();
            for (int i = 0; i <= n + 1; i++) p[i] = i;
            for (int i = 1; i <= n; i++) {
                for (int j = 0; j < 3; j++) {
                    a[i][j] = sc.nextInt();
                }
            }
            for (int i = 1; i <= n; i++) {
                for (int j = i + 1; j <= n; j++) {
                    if (dis(a[i], a[j]) <= 4L * r * r) {
                        merge(i, j);
                    }
                }
            }
            for (int i = 1; i <= n; i++) {
                if (a[i][2] <= r) merge(0, i);
                if (a[i][2] + r >= h) merge(n + 1, i);
            }
            out.println(find(0) == find(n + 1) ? "Yes" : "No");
        }
        out.flush();
    }

    static void merge(int a, int b) {
        int x = find(a);
        int y = find(b);
        p[x] = y;
    }

    static int find(int x) {
        if (p[x] != x) p[x] = find(p[x]);
        return p[x];
    }


    static long dis(long[] a, long[] b) {
        long s = 0;
        for (int i = 0; i < 3; i++) {
            s += (a[i] - b[i]) * (a[i] - b[i]);
        }
        return s;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
